#include <iostream>
using namespace std;
#include "vector.h"
#include <cstdlib>
#include <ctime>

int main() {
  using VECTOR::Vector;
  srand(time(nullptr));
  double dir;
  Vector step;
  Vector result(0.0, 0.0);
  unsigned long steps = 0;
  double target;
  double dstep;

  while (cin >> target) {
    cout << "enter step length:";
    if (!(cin >> dstep)) {
      break;
    }
    while (result.magval() < target) {
      dir = rand() % 360;
      step.set(dstep, dir, 'p');
      result = result + step;
      steps++;
    }
    cout << "After " << steps << " step,the subject " << endl;
    cout << result << endl;
    result.polar_mode();
    cout << "or\n" << result << endl;
    cout << "Average outward dis per step =" << result.magval() / steps << endl;
    steps = 0;
    result.set(0.0, 0.0);
  }
  cout << "done.." << endl;

  return 0;
}
